package com.hntech.base.sys;

import javax.tools.JavaCompiler;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import java.io.File;
import java.io.IOException;

/**
 * @Autho changqi.wu
 * @Date 路在脚下，使劲踩！
 */
public class Compiler {

    public static void main(String[] args) throws IOException {

        File javaFile = new File("E:\\2019\\java\\architecture\\java-skd\\src\\main\\java\\com\\hntech\\base\\Main.java");
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        StandardJavaFileManager manager = compiler.getStandardFileManager(null,null,null);
        Iterable it = manager.getJavaFileObjects(javaFile);
        JavaCompiler.CompilationTask task = compiler.getTask(null, manager, null, null, null, it);
        task.call();
        manager.close();

    }

}
